{extend name="common/base_page" /}

{block name="title"}业务字典{/block}

{block name="jscssfile"}{/block}

{block name="css"}
<style type="text/css">
body{ background: #ffffff; height:100vh; }
.layui-fluid {
    padding:10px 15px;
}
.layui-nav-tree { width: 100%; };
.layui-card { box-shadow: rgb(255 255 255 / 0%) 0px 0px 0px 0px; box-shadow: 0 0px 0px #ccc;}
.layui-nav { background:#ccc; color:#000000;}
.layui-nav-tree .layui-nav-item a{ color:#000000; }
.layui-nav-tree .layui-this, .layui-nav-tree .layui-this>a, .layui-nav-tree .layui-nav-child dd.layui-this, .layui-nav-tree .layui-nav-child dd.layui-this a {
    background:rgba(0,0,0,.1)!important;color:#ffffff;
}
.layui-nav-itemed>.layui-nav-child {
    background-color: rgba(0,0,0,.1)!important;
}
.layui-form-item .layui-inline {
     margin-bottom: 0px;
    margin-right: 0px;
}
</style>
{/block}

{block name="body"}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <!--left begin-->
        <div class="layui-col-md2" style="height:100vh;padding:0;">
            <div class="layui-card">
                <div class="layadmin-text">
                  <blockquote class="layui-elem-quote">
                    业务字典类型列表
                  </blockquote>
                </div>
                <ul class="layui-nav layui-nav-tree layui-inline mydictlist" lay-filter="component-nav-active" style="margin-right: 10px;">
                    {volist name="ywzd_list" id="vo"}
                    <li class="layui-nav-item">
                      <a href="javascript:;" data-idx="{$vo.id}" data-addurl="{$vo.add_url}">{$vo.name}</a>
                    </li>
                    {/volist}
                </ul>
            </div>
        </div>
        <!--left end-->

        <!--right begin-->
        <div class="layui-col-md10">

            <div class="layui-form-item" id="default_box_one">
                <a class="layui-btn layui-btn-normal" onclick="_addAction();">添加</a>
                <div class="layui-input-block" style="float: right;">
                  <form class="layui-form" action="">
                    <div class="layui-inline">
                      <label class="layui-form-label">状态</label>
                      <div class="layui-input-inline">
                        <select id="status" name="status">
                            <option value="ALL">所有</option>
                            <option value="0">已停用</option>
                            <option value="1">已启用</option>
                        </select>
                      </div>
                    </div>
                    <div class="layui-inline">
                      <div class="layui-input-inline">
                        <input type="text" name="keyword" id="keyword" maxlength="10" placeholder="请输入键词" autocomplete="off" class="layui-input">
                      </div>
                    </div>
                    <a class="layui-btn layui-btn-normal" onclick="_p = 1;_loadList();">搜索</a>
                    </form>
                </div>
            </div>

            <div class="layui-card" id="default_box_two">
                  <table id="LAY-app-content-comm" lay-filter="LAY-app-content-comm"></table>
                  <script type="text/html" id="statusTpl">
                    {{#  if(d.status){ }}
                      <button class="layui-btn layui-btn-xs">已启用</button>
                    {{#  } else { }}
                      <button class="layui-btn layui-btn-primary layui-btn-xs">已停用</button>
                    {{#  } }}
                  </script>
                  <script type="text/html" id="table-content-com">
                    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
                    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
                  </script>
            </div>

            <!--注射单来源 Begin-->
            <div id="default_box_three" style="display: none;">
              <div id="zsdly_dictset-transfer" class="dictset-transfer"></div>
              <div class="zsdly_save_btn">
                <a class="layui-btn layui-btn-normal" onclick="_saveZsdlyAction();">保存数据</a>
              </div>
            </div>
            <!--注射单来源 end-->

        </div>
        <!--right end-->
    </div>
</div>
{/block}

{block name="script"}
<script type="text/javascript">
var _p = 1, _isFirst = true, _dictText = '', _dictType = 'zhiwei', _addType= 'no', laytransfer = null;
layui.config({
  base: globalCfg.layuiBasePath //静态资源所在路径
}).extend({
  index: 'lib/index' //主入口模块
}).use(['index','transfer'], function(){
    var element = layui.element;
    laytransfer = layui.transfer;
    element.render('nav', 'component-nav');
    element.render('nav', 'component-nav-active');
    element.on('nav(component-nav-active)', function(elem){
      var _tmpType = elem.data('idx');
      if(_tmpType != _dictType || _isFirst)
      {
          if(_isFirst) _isFirst = false;
          _dictText = elem.text();
          _dictType = _tmpType;
          _addType = elem.data('addurl');
          _p = 1;
          _loadList();
      }
    });
});
$(function(){
  setTimeout(function(){
    $('.mydictlist li:first').children('a').trigger('click');
  },50);
});
</script>

{include file="js_template/tpl_ywzd" /}

<script src="__INDEX__/js/common/hz2pinyin.js"></script>
<script src="__INDEX__/js/common/hz2wubi.js"></script>
<script src="__INDEX__/js/common/commonUtils.js?v={$site.version}"></script>
<script src="__INDEX__/js/zidian/yewuzidian.js?v={$site.version}"></script>

<script type="text/javascript">
//加载数据
function _loadList()
{
  if(_dictType == 'zsdly')
  {
    $('#default_box_one').hide();
    $('#default_box_two').hide();
    $('#default_box_three').show();
    _Index.ajax("{:url('index/dictionary.yewuzd/load_clinic_zsdly')}",{dicttype:_dictType},function(d){
        if(d.err == 0)
        {
          //显示搜索框
          laytransfer.render({
            id: 'transfer_key_1' //定义唯一索引
            ,elem: '#zsdly_dictset-transfer'
            ,width:400
            ,height:500
            ,data: d.data_left
            ,value:d.data_right
            ,title: ['待选择的用法', '已选择的用法']
            ,showSearch: true
          });
            
        }else{
            layer.msg(d.msg, {time: 2000,anim: 4});
        }
    },'');
  }else{
      $('#default_box_one').show();
      $('#default_box_two').show();
      $('#default_box_three').hide();
      __showLoadingBox('请稍候...');
      laytable.render({
          elem: '#LAY-app-content-comm'//指定表格元素
          ,url:"{:url('index/dictionary.yewuzd/index')}"
          ,method:'post'  //提交方式
          ,where:{keyword:$.trim($('#keyword').val()),status:$.trim($('#status').val()),page:_p,dicttype:_dictType} //post json数据
          ,page: {layout: ['count', 'prev', 'page', 'next', 'skip'],first: true,last: true}
          ,skin: 'line '  //表格风格 line （行边框风格）row （列边框风格）nob （无边框风格）
        　,even: true    //隔行换色
          ,limit: 20     //每页默认显示的数量
          ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
          ,height: 'full-100' //表格高度，layui 2.2.1 新增 , full-100 为适应最大高度或其它数值500
          ,cols: getTableConfigField()
          ,done:function(datalist,curr,page){
              __hideLoadingBox();
          }
      });

      laytable.on('tool(LAY-app-content-comm)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
          var _data = obj.data; //获得当前行数据
          var _event = obj.event; //获得 lay-event 对应的值
          if(_event === 'edit'){ //编辑
              _addAction(_data);
          }
          if(_event === 'del'){ //删除
            layer.confirm('您确定要删除本条数据吗？', {
                title:'删除',shade:[0.4,'#000000'],btn: ['确定','取消'] //按钮
            }, function(){
                layer.closeAll();
                _Index.ajax("{:url('index/dictionary.yewuzd/del')}",{id:_data.id,dicttype:_dictType},function(d){
                    if(d.err == 0)
                    {
                      obj.del();
                      layer.msg(d.msg, {time: 1000},function(){
                          laytable.reload('LAY-app-content-comm');
                      });
                    }else{
                      layer.msg(d.msg, {time: 2000,anim: 4});
                    }
                },'请稍候...');
            });
          }
      });
  }
}
//保存注射单来源
function _saveZsdlyAction()
{
  var _data = laytransfer.getData('transfer_key_1');
  _Index.ajax("{:url('index/dictionary.yewuzd/save_clinic_zsdly')}",{dicttype:_dictType,json:_data},function(d){
      if(d.err == 0)
      {
          layer.msg(d.msg, {time: 1000});
      }else{
          layer.msg(d.msg, {time: 2000,anim: 4});
      }
  },'');
}
</script>
{/block}